﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _超市收银系统
{
    /// <summary>
    /// 折扣返还现金
    /// </summary>
    internal class DiscountMoney :DiscountFather
    {
        //买 M元送 N元
        //买的钱 M
        public double RealM { get; set; }
        //送的钱 N
        public double RealN { get; set; }

        public DiscountMoney(double realM,double realN)
        {
            this.RealM = realM;
            this.RealN = realN;
        }
        public override double GetTotalMoney(double realMoney)
        {
            //若达到返现条件就返现 realM元，不满足返现就返回原值
            if (realMoney >= this.RealM)
            {
                return realMoney - (int)(realMoney / this.RealM) * this.RealN;
            }
            else
            {
                return realMoney;
            }
        }
    }
}
